<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>后台管理系统</title>
        <meta name="author" content="BaiYY"/>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="renderer" content="webkit">
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/pages.css"/>
        <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/time.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/pages.js"></script>
    </head>
<body>
    <div class="right-sidebar" style="max-width: 1200px;">
        <ul class="nav nav-tabs" style="margin-bottom: 16px" role="tablist">
            <li role="presentation"><a href="playerManage.html">ID查询</a></li>
            <li role="presentation" class="active"><a href="nicknameSearch.html">昵称查询</a></li>
        </ul>

        <div class="input-group col-md-12" style="margin: 10px auto;">
            <input type="text" class="form-control" placeholder="请输入玩家昵称" name="nickname" id="nickname">
            <span class="input-group-addon" id="cbtn">查询</span>
        </div>
        <section class="table-responsive">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>玩家ID</th>
                    <th>微信昵称</th>
                    <th>剩余{:L(GAME_RESOURCE)}</th>
                    <th>剩余金币</th>
                    <th>注册时间</th>
                    <th>上次登录时间</th>
                </tr>
                </thead>
                <tbody id="dataList"></tbody>
            </table>
        </section>
        <ul class="page" id="page" style="width: 100%;overflow: hidden;"></ul>
    </div>
    <script type="text/javascript">
        $(function () {
            $("#cbtn").on("click",function () {
                var nickname = $.trim($("#nickname").val());
                if(nickname == '' || nickname == null) {
                    alert("昵称不能为空！");
                }
                $.ajax({
                    type:"get",
                    url:"{:U('Admin/Main/getNickName')}?name="+nickname,
                    success: function (data) {
                        console.log(data);
                        var datas = data.arr;
                        if(data == 'error') {
                            alert("抱歉,未查询到相关数据！");
                            window.location.href="{:U('Admin/Main/nicknameSearch')}";
                        }else{
                            if(data.arr.length>=1) {
                                options={
                                    "id":"page",//显示页码的元素
                                    "data":datas,//显示数据
                                    "maxshowpageitem":2,//最多显示的页码个数
                                    "pagelistcount":10,//每页显示数据个数
                                    "callBack":function(data) {
//                                        console.log(data);
                                        var str = '';
                                        var txt = '';
                                        var sTime = '';
                                        for(var i=0;i<data.length;++i) {
                                            if(data[i].marks.logoutTime) {
                                                sTime = 0;
                                            }else{
                                                sTime = getLocalTime(data[i].marks.logoutTime);
                                            }
                                            if(data[i].status.coin == null) {
                                                txt = 0;
                                            }else{
                                                txt = data[i].status.coin;
                                            }
                                            str +="<tr><td>"+data[i]._id+"</td><td>"+data[i].info.name+"</td><td>"+data[i].status.card+"</td><td>"+txt+"</td><td>"+getLocalTime(data[i].info.createTime)+"</td><td>"+sTime+"</td></tr>"
                                        }
                                        $("#dataList").html(str);
                                    }
                                }
                                page.init(datas.length,1,options);
                            }else{
                                $("#dataList").html("暂时未查询到相关数据！");
                            }
                        }
                    }
                })
            })
        })
    </script>
</body>
</html>